const getComponentsName = fileName => {
  return fileName
    .split("/")[1]
    .replace(/\.vue$/, "")
    .replace(/^\w/, c => c.toUpperCase());
};

// eslint-disable-next-line no-undef
const requireComponent = require.context("./", true, /\.vue$/);
const cmps = {};
requireComponent.keys().forEach(fileName => {
  const config = requireComponent(fileName);
  const componentName = getComponentsName(fileName);
  cmps[componentName] = config.default || config;
});

export default cmps;
